// 导入子路由
import Layout from "@/pages/Layout"
import New from "@/pages/New"
import Month from "@/pages/Month"
import Year from "@/pages/Year";
// 导入createBrowserRouter,作用是创建路由
import { createBrowserRouter } from "react-router-dom";
import { Navigate } from "react-router-dom";
// 创建路由实例对象
const router = createBrowserRouter([
  // 根路径重定向配置
  {
    path: "/",
    element: <Navigate to="/layout/month" replace />, // 重定向到目标路径
  },
  {
    path: '/layout',
    element: <Layout />,
    children: [
      {
        index: true, // 默认子路由
        element: <Month /> // 访问/article时默认显示
      },
      {
        path: 'year',
        element: <Year />
      },
      {
        path: 'month',
        element: <Month />
      },
      {
        path: 'new',
        element: <New />
      }
    ]
  },
])
// 导入路由实例对象
export default router;